<template>
    <div id="box">
        <div class="container">
            <div class="con">
                <div class="head">
                    <div class="headCon">
                        <div class="headLeft">
                            <span class="userName">{{user.nick}}</span>
                            <span class="msg">再忙，也要记得吃饭哟~</span>
                        </div>
                        <div class="headRight">
                            <img :src="$url+user.avatar" alt="">
                        </div>
                    </div>
                </div>
                <div class="vipBox">
                    <div class="vipBoxCon">
                        <div>
                            <i class="el-icon-present"></i>
                            <p>超级会员</p>
                        </div>
                        <div>
                            <span>开通后，每月领 <p>20</p> 元红包</span>
                            <i class="el-icon-arrow-right"></i>
                        </div>
                    </div>
                </div>
                <div class="content">
                    <div class="contentCon">
                        <div class="wallet">
                            <i class="el-icon-money"></i>
                            <p>钱包</p>
                        </div>
                        <div>
                            <i class="el-icon-files"></i>
                            <p>优惠券</p>
                        </div>
                        <div>
                            <i class="el-icon-star-off"></i>
                            <p>我的收藏</p>
                        </div>
                        <div @click.stop="drawer=!drawer">
                            <i class="el-icon-setting"></i>
                            <p>设置</p>
                        </div>

                    </div>
                </div>
                <div class="foot">
                    <el-button type="danger" @click.stop="dialogVisible = true" round>退出登录</el-button>
                    <el-dialog
                            title=""
                            :visible.sync="dialogVisible"
                            width="80%"
                            :center="true"
                            :destroy-on-close="true"
                            style="margin-top: 20vh"
                            :show-close="false">
                        <span>确定退出吗</span>
                        <span slot="footer" class="dialog-footer">
                            <el-button @click.stop="dialogVisible = false">取 消</el-button>
                            <el-button :loading="loading" type="primary" @click.stop="logout">确 定</el-button>
                        </span>
                    </el-dialog>
                    <el-drawer
                            title="设置"
                            :visible.sync="drawer"
                            :direction="'btt'"
                            :destroy-on-close="true"
                            size="100%">
                        <setting></setting>
                    </el-drawer>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import setting from './setting.vue'
    export default {
        name: "meInfo",
        data(){
            return {
                dialogVisible: false,
                drawer: false,
                user:'',
                loading:false,
            }
        },
        components:{
            setting
        },
        created() {
            this.user = this.$store.state.user
        },
        methods: {
            handleClose(done) {
                this.$confirm('确认关闭？')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {});
            },
            logout(){
                this.loading=true

                setTimeout(()=>{
                    this.dialogVisible = false
                    sessionStorage.removeItem('token')
                    sessionStorage.removeItem('user')
                    this.$emit('isLogout')
                    this.loading=false
                },1000)
            }

        }
    }
</script>

<style lang="less" scoped>
    .content{
        margin-top: 5px;
        width: 100%;
        display: flex;
        justify-content: center;

        .contentCon{
            width: 100%;
            display: flex;
            justify-content: space-between;
            div{
                width: 80px;
                height: 80px;
                border-radius: 10px;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: center;
                background: white;
                i{
                    font-size: 25px;
                    margin-bottom: 5px;
                }
            }
        }
    }
    .foot{
        margin-top: 350px;
        display: flex;
        align-self: center;
        justify-content: center;
    }
    #box{
        display: flex;
        height: 650px;

    }
    .container{
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    .con{
        width: 95%;
    }
    .head{
        margin-top: 10px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .headCon{
        width: 95%;
        display: flex;
        flex-direction: row;

    }
    .headLeft{
        display: flex;
        flex-direction: column;
        flex: 1;
        justify-content: space-around;
        .userName{
            font-size: 30px;
            font-weight: 800;
        }
        .msg{
            color: #9E9E9E;
            font-weight: 800;
        }
    }
    .headRight{
    width: 90px;
    img{
        border-radius: 50%;
        width: 100%;
    }
    }
    .vipBox{
        display: flex;
        justify-content: center;
        align-items: center;
        height: 50px;
        margin-top: 20px;
        border-radius: 10px;
        background: #FCE9C9;
        .vipBoxCon{
            width: 95%;
            justify-content: space-between;
            display: flex;
            flex-direction: row;
            div{
                display: flex;
                flex-direction: row;
                align-items: center;
                justify-content: center;
                p{
                    margin: 0 5px;
                    color: #644B30;
                    font-weight: 800;
                }
                span{
                    display: flex;
                    flex-direction: row;
                    align-items: center;

                    p{
                        color:#F46A53 ;
                        font-size: 20px;
                    }
                }
                .el-icon-present{
                    margin-right: 5px;
                    font-size: 25px;
                    color: #FFCA0D;
                    font-weight: 800;
                }
                .el-icon-arrow-right{
                    font-size: 20px;
                    margin-left: 5px;
                }
            }
        }

    }

</style>